package com.kfm.pm;

import java.util.Arrays;

public class Exec07 {

    public static void main(String[] args) {
        // 编写一个方法，接受一个字符数组，将其翻转并输出。
        char[] chs = {'开', '发', '喵'};
//        char[] reverse = reverse1(chs);
//        System.out.println(Arrays.toString(reverse));
        reverse1(chs);
        System.out.println(Arrays.toString(chs));
    }

    public static char[] reverse(char[] arr) {
        char[] newArr = new char[arr.length];
        for (int i = 0; i < arr.length; i++) {
            newArr[arr.length - 1 - i] = arr[i];
        }
        return newArr;
    }

    public static void reverse1(char[] arr) {
        for (int i = 0; i < arr.length / 2; i++) {
            char temp = arr[i];
            arr[i] = arr[arr.length - 1 - i];
            arr[arr.length - 1 - i] = temp;
        }
    }
}
